export default {
  before(from, to, next, store) {
    if (!store && to.name != 'Home') {
      console.log("redirected to 'Home'");
      next({ name: 'Home' })
      // return { name: 'Home' };
    } else if (this.loginFreeItems.indexOf(to.name) > -1) {
      next();
      // return null;
    } else if ((store.state.login.status < 0)) {
      console.log("from '" + from + "' redirected to 'Notice'");
      store.commit('setRouterNext', to.name);
      next({ name: 'Notice', params: { reason: "login" } });
      // return { name: 'Notice' };
    } else {
      next()
      // return null;
    }
  },

  loginFreeItems: [
    "Home",
    "Notice",
    "Changelog",
    "TODO"
  ]
}